const  enterpriseMode = require("../models/enterpriseModel");
const {getDataByPage,uploading} = require("../utils/tools");



// 添加企业
exports.createEnterprise = (info)=>{
   return enterpriseMode.create(info)
}


// 修改企业
exports.updateEnterprise = (id,info)=>{
    return enterpriseMode.updateOne({_id:id},info)
}

// 删除企业
exports.deleteEnterprise = (id)=>{
    return enterpriseMode.deleteOne({_id:id})
}


// 分页获取企业
exports.findByPageEnterprise = (queryInfo)=>{
    console.log(uploading)
    return getDataByPage(enterpriseMode,queryInfo,"user");
}

// 通过ID获取企业
exports.findOneById = (id)=> {
    return enterpriseMode.findOne({
        _id:id
    })
}


// 通过用户ID获取企业
exports.findOneByUserId = (userId)=> {
    console.log(userId)
    return enterpriseMode.findOne({
        user:String(userId),
    })
}
